/**
 * @filename AuthInterceptor.java
 */
package com.liupf.interceptor;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;

/**
 * @description 权限拦截器
 * @author shevliu
 * @email shevliu@gmail.com
 * Jul 26, 2012 9:47:40 PM
 */
public class AuthInterceptor implements Interceptor{

	private Log log = LogFactory.getLog(AuthInterceptor.class) ;
	
	
	public void intercept(ActionInvocation ai) {
		HttpSession session = ai.getController().getRequest().getSession();
		String userName = (String) session.getAttribute("userName");
		if(userName == null || "".equals(userName)){
			log.error("用户未登录，返回登录界面");
			ai.getController().redirect("/login.html");
			return ;
		}
		ai.invoke();
	}

}
